<div class="page page-full bg-white animation-fade">
    <div class="page-aside">
        <div class="page-aside-switch">
            <i class="icon wb-chevron-left" aria-hidden="true"></i>
            <i class="icon wb-chevron-right" aria-hidden="true"></i>
        </div>
        <div class="page-aside-inner height-full" data-toggle="slimScroll">
            <div class="page-aside-section">
                <h5 class="page-aside-title">字典类型</h5>
                <div class="list-group has-actions top-menu" data-toggle="ListGroup" id="dictType_list">
                    <script id="dictTypeTable" type="text/html">
                        {{each data as value index}}
                        <div class="list-group-item" onclick="Page.Dict.selectTable('{{value.id}}');">
                            <div class="list-content">
                                <span>{{value.name}}</span>
                            </div>
                            <div class="item-actions">
                                <span class="btn btn-pure btn-icon" data-toggle="dialog"
                                      data-options={url:"${base}/admin/sys/dict/createDict?id={{value.id}}",onClose:Page.Dict.getAllDictTyp}>
                                    <i  class="icon glyphicon glyphicon-edit"></i>
                                </span>
                                <span class="btn btn-pure btn-icon" data-toggle="doDel"
                                      data-options={url:"${base}/admin/sys/dict/delDict?id={{value.id}}"}>
                                    <i class="icon glyphicon glyphicon-remove"></i>
                                </span>
                            </div>
                        </div>
                        {{/each}}
                    </script>
                </div>

            </div>
            <div class="page-aside-section hidden-xs pull-right">

                <div class="btn-group dropup " user="group">
                    <a type="button" class="btn btn-info"  data-toggle="dialog"
                       data-options="{url:'${base}/admin/sys/dict/createDict',onClose:Page.Dict.getAllDictTyp}">
                        <i class="fa fa-plus-square-o" aria-hidden="true"></i> 添加
                    </a>
                </div>

            </div>
        </div>
    </div>
    <div class="page-main">
        <div class="page-header">
            <h1 class="page-title">字典名称</h1>
            <div class="page-header-actions" id="dictToolBar">
                <a class="btn btn-primary" href="#" onclick="Page.Dict.createDict()">
                    <i class="fa fa-plus" aria-hidden="true"></i> 添加
                </a>
                <a class="btn btn-primary" href="${base}/admin/sys/dict/saveOrUpdateDictDetail?id={{id}}" data-toggle="edit">
                    <i class="fa fa-pencil-square-o" aria-hidden="true"></i> 编辑
                </a>
                <a class="btn btn-danger"  href="${base}/admin/sys/dict/delDictDetail" href="#" data-toggle="del">
                    <i class="fa fa-trash-o" aria-hidden="true"></i> 删除
                </a>
            </div>
        </div>
        <div class="page-content">
            <@dataGrid  id="sys_dict_detail_table"/>
        </div>
    </div>

</div>

<script type="text/javascript">
    $.namespace('Page.Dict');
    Page.Dict = function () {
        var  currentDictId ;
        return {

            init: function () {
                Page.Dict.initDictTable();
                Page.Dict.getAllDictTyp();
            },
            initDictTable:function () {
                $("#sys_dict_detail_table").boltDataGrid({
                    width:'100%',
                    height:'full-220',
                    pagination:true,
                    toolbar: '#dictToolBar',
                    dataUrl: '${base}/admin/sys/dict/page',
                    queryParams:{dictId:'0'}
                });
            },

            createDict:function(){
                $(this).dialog({
                    title: "字典详情",
                    url: "${base}/admin/sys/dict/createDictDetail?dictId="+currentDictId
                });
            },
            getAllDictTyp: function (v) {
                Bolt.ajax('doajax', {
                    url: '${base}/admin/sys/dict/getAllDictType',
                    type:"GET",
                    loadingmask: true,
                    okCallback: function (datas) {
                        var html = template('dictTypeTable', {data: datas});
                        $('#dictType_list').empty().html(html);
                    }
                })
            },

            selectTable:function (dictId) {
                currentDictId = dictId;
                if(!currentDictId){
                    Bolt.notify("warning", "请选择字典类型");
                    return;
                }
                $('#sys_dict_detail_table').boltDataGrid('refresh',{dictId:currentDictId});
            },
            operation:function() {
                var html =
                    '<div data-toggle="rowToolbar">'
                    + ' <a class="btn btn-info"   href="${base}/admin/sys/dict/createDictDetail?id={{id}}"  data-toggle="edit">编辑</a>'
                    + ' <a class="btn btn-danger" href="${base}/admin/sys/dict/delDictDetail" data-toggle="del">删除</a></div>';
                return html
            }
        }


    }();
    $(document).ready(function () {
        Page.Dict.init();
    });

</script>

